package com.dy.controller;


import com.dy.VO.DepartmentVO;
import com.dy.entity.Department;
import com.dy.response.Result;
import com.dy.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dy
 * @since 2022-03-02
 */
@Api(value="部门系列",tags = "部门系列")
@CrossOrigin
@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    DepartmentService departmentService;

    @ApiOperation(value="查询所有的部门及其人数")
    @GetMapping("/findAll")
    public Result findAll(){
        List<DepartmentVO> departmentCountAndName = departmentService.findDepartmentCountAndName();
        return Result.ok().data("departmentList",departmentCountAndName);
    }

}

